<!-- 火灾报警系统 -->
<template>
  <div class="data-info">
    <ul class="list-info">
      <li v-for="item in dataListStyleData" :key="item.index">
        <dataListStyle1 :item-data="item"/>
      </li>
    </ul>
  </div>
</template>
<script>
import { fasList } from '@/api/internetData'
import dataListStyle1 from './dataListStyle1.vue'
import { parseTime } from '@/utils/index'
export default {
  components: {
    dataListStyle1
  },
  data() {
    return {
      dataListStyleData: []
      // {
      //   mname: '主机',
      //   position: '配电间',
      //   date: '2020-01-01',
      //   park_name: '南行旺苑',
      //   building_name: '6号楼',
      //   firePoint: 0,
      //   faultPoint: 0,
      //   shieldPoint: 0,
      //   active: 'true',
      //   otherInfo: true,
      //   leftClass: 'left-strip',
      //   device_id: 123333,
      //   list: [{
      //     name: '主电'
      //   }, {
      //     name: '自动'
      //   }, {
      //     name: '联动'
      //   }, {
      //     name: '设备'
      //   }]
      // }
    }
  },
  computed: {
  },
  created() {
    this.$nextTick(function() {
      this.getList()
    })
  },
  methods: {
    getList() {
      fasList()
        .then(response => {
          const data = response.data
          if (data.code === 40000) {
            this.dataListStyleData = []
            data.data.forEach(item => {
              item.list = [{
                name: item.main_power_state === '187465693247033' ? '正常' : '故障',
                active: item.main_power_state === '187465693247033' ? 'active' : 'onActive'
              }, {
                name: item.manual_automatic_state === '187469071498221' ? '自动' : '手动',
                active: item.manual_automatic_state === '187469071498221' ? 'active' : 'onActive'
              }, {
                name: item.linkage_state === '187467990265183' ? '停止' : '动作',
                active: item.linkage_state === '187467990265183' ? 'active' : 'onActive'
              }, {
                name: item.device_state === '187465693247033' ? '正常' : '故障',
                active: item.device_state === '187465693247033' ? 'active' : 'onActive'
              }]
              item.lastTime = item.lastTime ? parseTime(item.lastTime * 1000, '{y}-{m}-{d} {h}:{i}:{s}') : ''
              item.active = item.online_state === '187469382053710' ? 'true' : 'false'
              item.otherInfo = true
              item.leftClass = item.online_state === '187469382053710' ? 'left-strip' : 'left-strip active'
              this.dataListStyleData.push(item)
            })
          } else {
            this.$message.warning(response.data.message)
          }
        })
        .catch(() => {
        })
    }
  }
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.data-info{
}
.list-info{
  overflow: hidden;
  li{
    float: left;
    margin-right: 20px;
    margin-left: 4px;
  }
}
</style>
